<?php
// thumbnail options
$defaults = array(
    'quality'   => 100,
    'zc'        => true,
    'zc_align'  => 'c'
);
$opts = get_post_meta( get_the_ID(), 'dt_post_thumb_opts_options', true );
$opts = wp_parse_args( $opts, $defaults );

// gallery order options
$defaults = array(
    'orderby'           => 'menu_order',
    'order'             => 'ASC',
    'hide_thumbnail'    => false
);
$opts_oder = get_post_meta( get_the_ID(), 'dt_gallery_order', true );
$opts_oder = wp_parse_args( $opts_oder, $defaults );
?>

<?php
$thumbnail_id = get_post_thumbnail_id(get_the_ID());

// album thumbnail
$thumb = dt_get_thumbnail(
    array(
        'img_id'	=> $thumbnail_id,
        'width'		=> 290,
        'height'	=> 150,
        'upscale'	=> $opts['zc'],
        'zc_align'  => $opts['zc_align'],
        'quality'   => $opts['quality']
    )
);

// big image
$big = wp_get_attachment_image_src($thumbnail_id, 'large');

// get album images
$query = array(
    'post_type'			=> 'attachment', 
    'post_mime_type'	=> 'image',
    'post_status'		=> 'inherit',
    'orderby'			=> $opts_oder['orderby'],
    'order'				=> $opts_oder['order'],
    'posts_per_page'	=> -1,
    'post_parent'		=> get_the_ID(),
);

// further option
if( $opts_oder['hide_thumbnail'] ) {
    $query['post__not_in'] = array($thumbnail_id);
}

$images = '';

$images = new Wp_Query( $query );
$images = $images->posts;

$title = esc_attr(get_the_title());

$post->post_excerpt = wp_kses(
    $post->post_excerpt,
    array(
        'span' => array ( 
            'class'     => array (),
            'dir'       => array (),
            'align'     => array (),
            'lang'      => array (),
            'style'     => array (),
            'title'     => array (),
            'xml:lang'  => array ()
        )
    )
);
?>

<div class="highslide-gallery">
    
    <a id="gal_<?php the_ID(); ?>" class="col_1-3 dt_album_cover" href="<?php echo $big[0]; ?>" title="<?php echo $title; ?>">
        <div class="loading-image">
            <img src="<?php echo $thumb['thumnail_img']; ?>" alt="<?php echo $title; ?>"/>
        </div>
        <div class="mask"></div>
        <div class="desc">
            <h4><?php echo $title; ?></h4>
            <div class="desc_text"><?php the_excerpt(); ?></div>
        </div>
    </a>

<?php if( !empty($images) && !post_password_required( get_the_ID() ) ): ?>
    <div class="hidden-container">
        <?php
        // print gallery
        foreach( $images as $image ):
            $thumb = dt_get_thumbnail(
                array(
                    'img_id'	=> $image->ID,
                    'width'		=> 100,
                    'upscale'	=> true,
                    'quality'   => 100
                )
            );
            $big = wp_get_attachment_image_src($image->ID, 'large');
            $title = esc_attr( $image->post_title );
        ?>
            <a class="highslide" href="<?php echo $big[0]; ?>" data-src="<?php echo $thumb['thumnail_img']; ?>" onclick="return hs.expand(this, { slideshowGroup: <?php the_ID(); ?> })"><?php echo $title; ?></a>
            
            <div class="highslide-caption">
                <?php echo apply_filters('the_excerpt', $image->post_excerpt); ?>
            </div>
        
        <?php endforeach ?>
    </div>
<?php endif ?>
</div>